Skip to content

Conversation

@laoneo
Copy link
Member

@laoneo laoneo commented Feb 2, 2018

Ongoing effort to phase out getInstance code. This pr deprecates Pathway::getInstance.

@wilsonge and @mbabker can the code which gets the pathway from the factory being removed here?

I'm splitting #16918 into different pr's to be easier to review.

@wilsonge
Copy link
Contributor

wilsonge commented Feb 5, 2018

I'm unsure about this - the pathway is constant for a given page - we shouldn't load this multiple times. If we aren't doing a getInstance it at least needs to be in the container and retrieved consistently through the container. We shouldn't be recommending creating a fresh instance each time

@laoneo
Copy link
Member Author

laoneo commented Feb 5, 2018

True, was a bit in a rush and didn't saw that it caches the instances per client. Sounds like another factory in the container. Do we want to go that way?

@wilsonge
Copy link
Contributor

wilsonge commented Feb 5, 2018

I think just do it like the application in the container yeah? This ones kinda weird because there isn't an Admin Pathway (at least at the moment) - although with the admin menu changes in 3.8 it wouldn't totally surprise me if one came along at some point

@laoneo
Copy link
Member Author

laoneo commented Feb 5, 2018

Modified the pr to get the pathway object from the container by a service provider. Changed the deprecate message to get the pathway from the app, as every core extension does already.

@mbabker
Copy link
Contributor

mbabker commented Feb 7, 2018

A little late to the party here, but...

Shouldn't there just be a $this->pathway property on the application object? If it's supposed to be persistent for the lifetime of the request, the pathway object should be very closely bound to the active application and should live as a property there instead of always being reliant on fetching the object out of the container (we can still use the container to build the initial service, and we should drop the unused options param from the constructor as well).

*/
public function register(Container $container)
{
$container->alias('SitePathway', SitePathway::class)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nitpick. IMO container keys should either be class names or some kind of dot separated key like you use for Registry options. So this particular service should have one key and two aliases:

  • SitePathway::class (already in place)
  • JPathwaySite (legacy class name)
  • pathway.site (this is a pathway service and the second part of the key specifies a specific sub-object, this also does not block potential future use of a pathway key if we have other apps supporting one and in the future if we had it we'd add a pathway.administrator service).

@laoneo
Copy link
Member Author

laoneo commented Feb 7, 2018

Added your input.

@wilsonge wilsonge merged commit d1a2c6f into joomla:4.0-dev Feb 11, 2018
@wilsonge wilsonge added this to the Joomla 4.0 milestone Feb 11, 2018
@wilsonge wilsonge deleted the j4/deprecate/pathway branch February 11, 2018 12:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants